package com.example.learnspringboot06datajdbc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class HelloController {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @ResponseBody
    @GetMapping("/queryDepartment")
    public List<Map<String, Object>> queryDepartment(){
        List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from department");
        return list;
    }

    @ResponseBody
    @GetMapping("/queryEmployee")
    public List<Map<String, Object>> queryEmployee(){
        List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from employee");
        return list;
    }
}
